<extend name="Layout/ins_page" />
<block name="content">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php if (!session_id()) session_start();date_default_timezone_set('PRC'); ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>授权列表</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
        <script src="/sap/scripts/boot.js" type="text/javascript"></script>
        <style>

        </style>

    </head>
    <body >


    <!--<fieldset id="fd1" style="border: 1px solid #e5e5e5;height: 50px">-->
        <!--<legend><span></span></legend>-->
        <!--<div  id='fm1'>-->
            <!--<div class="fieldset-body">-->

                <!--<input id="combo1" class="mini-combobox" style="width:320px;" textField="name" valueField="id" emptyText="请选择问题种类..."  url="/Wkorder/getQuestionCategory" value=""  allowInput="true" showNullItem="true" nullItemText="请选择清单..."/>-->

                <!--<br/>-->
            <!--</div>-->
        <!--</div>-->
    <!--</fieldset>-->

    <!--<div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false" buttons="#tabsButtons"></div>-->

    <div>
        选择问题类型：
        <ul id="tree1" class="mini-tree" url="/Wkorder/getQuestionCategory" style="width:200px;padding:5px;"
            showTreeIcon="true" textField="text" idField="id" parentField="pid" resultAsTree="false"
            onbeforenodeselect="onBeforeNodeSelect"
            showRadioButton="true" showFolderCheckBox="false" expandOnLoad="false">
        </ul>
    </div>

    <div>
        请求人：
        <br>
        <input id="q_request_man" name="q_request_man" class="mini-combobox" style="width:300px;" textField="name" valueField="emp_no" emptyText="选择用户..."  url="/Wkorder/getUserlist" value=""  allowInput="true" showNullItem="true" nullItemText="选择用户..."/>
    </div>

    <div>
        问题主题：
        <br>
        <input id="q_subject"  name="q_subject" class="mini-textbox" required="true" width='300px'/>
    </div>

    <div id='editForm1'>
        问题细节：

        <textarea  class="editor" id="remarks" name="remarks" class="col-xs-12"></textarea>

        <br />

        <input id='checkInput' name='checkInput' type="hidden" value="didnotselect"  />


        <a class="mini-button" onclick="save" enabled="" id='saveBtn' style="">&nbsp;&nbsp;添加&nbsp;&nbsp;</a>
        <a class="mini-button" onclick="clear" enabled="" id='colse-tb'>&nbsp;&nbsp;取消&nbsp;&nbsp;</a>
    </div>
    </body>
    <script type="text/javascript">

        mini.parse();

        var tree = mini.get("tree1");
        var saveBtn = mini.get("saveBtn");

        function onBeforeNodeSelect(e) {
            var tree = e.sender;
            var node = e.node;
            //var checkInput = mini.get("checkInput");
            //checkInput.setValue('Y');
            $("#checkInput").val('Y');
        }

        function save() {

            // 检查主题是否为空
            var qSubject = mini.get("q_subject").getValue();
            if(qSubject==''){
                mini.alert('请填写问题主题');
                return ;
            }

            //var checkInput = mini.get("checkInput").getValue();
            var checkInput = $("#checkInput").val();
            // 检测问题种类是否选中by checkInput
            if(checkInput == "didnotselect" ){
                mini.alert('请选择问题类型');
                return ;
            }

            var tree = mini.get("tree1");
            var node = tree.getSelectedNode();
            var categoryID = node.id;
            //return;

            var remarks = tinyMCE.activeEditor.getContent() ;
            if(remarks==''){
                mini.alert('请填写问题细节');
                return ;
            }

            var qRequestMan = mini.get("q_request_man").getValue();

           // mini.mask({
           //     el: document.body,
           //     cls: 'mini-mask-loading',
           //     html: '保存中...'
           // });

            saveBtn.setEnabled(false);

            $.ajax({
                url: "/wkorder/docreatedp20171120",
                data: { categoryID: categoryID, qSubject: qSubject, qRequestMan: qRequestMan,remarks:remarks},
                type: "post",
                success: function (text) {
                    if(text>0){
                        mini.unmask(document.body);
                        tinyMCE.activeEditor.setContent(' ') ;
                        mini.alert('新增成功');
                        saveBtn.setEnabled(true);
                        clear();
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

        function clear(){
            grid.setData(null);
            mini.get('remarks').setValue("");
        }

    </script>
    </html>
</block>